<?php
	
	namespace Aspic\Form\Element;
	
	/**
	* Hidden Textbox form element
	*/
	class HiddenTextBox extends AbstractValidatableElement {

		public function __construct($name, $value = '', array $options = array(), array $attributes = array()) {
			parent::__construct($name, $options, $attributes);
			
			$this->setShowAsLine(false);
			
			$this->attr('value', $value);
		}
		
		public function outElement() {
			$out = '<input type="hidden"'.$this->getAttrsAndNameStr().'/>';

			return $out;
		}
		
		public function bind(array $formData = null)  {
			// Value could be an array when javascript dynamically duplicates the input (so, that could not be managed by the element)
			if(($value = $this->getValue($formData)) AND !is_array($value)) {
				$this->attr('value', $value);
			}
		}
		
	}
	
?>